﻿/*
-------------------------------------------------------------------------------------------------------------
JQuery Extended Functions
Name:zsi.JQueryExtendedFunctions.js
Description: 
   Extended functions of JQuery's objects like Html<Select>, and html<table>
Developer : Date Modified :  Reason
GMF   : 06/21/2010    :  Started the Places class          
GMF   : 08/07/2010    :  added ToEmpty function

----------------------------------------------------------------------------------------------
*/
$.fn.clearSelect = function() {
    var obj = this[0];
    if (obj) {
        if (obj.tagName.toLowerCase() == "select") {
            obj.options.length = 0;
        }
    }
}

$.fn.fillSelect = function(data) {
    this.clearSelect();
    var ddl = this[0];
    if (ddl) {
        if (ddl.tagName.toLowerCase() == 'select') {
            $.each(data, function(index, optionData) {
                var option = new Option(optionData.Text, optionData.Value);
                if ($.browser.msie) {
                    ddl.add(option);
                }
                else {
                    ddl.add(option, null);
                }
            });
            
            if (zsi.Util.Common) zsi.Util.Common.LoadingBar(false);
        } 
    }
}

$.fn.clearGrid = function() {
    var t = $($(this).children("tbody")).children("tr");
    t.each(function() {
        var th = $(this).children()[0];
        if (th.tagName.toLowerCase() != "th") {
            $(this).remove();
        }
    });
}

$.fn.ToEmpty = function() {
    return this.selector;
}